<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>枣庄农商银行网上营业厅</title>

<link rel="stylesheet" type="text/css"
	href="js/bootstrap-3.3.0-dist/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="css/layout.css" />
<link type="text/css" rel="stylesheet" href="css/validation.css" />

<script type="text/javascript"
	src="js/bootstrap-3.3.0-dist/js/time.js"></script>

<script type="text/javascript"
	src="js/bootstrap-3.3.0-dist/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript"
	src="js/bootstrap-3.3.0-dist/js/jquery.validate.min.js"></script>
<script type="text/javascript"
	src="js/bootstrap-3.3.0-dist/js/additional-methods.js"></script>
<script type="text/javascript"
	src="js/bootstrap-3.3.0-dist/js/bootstrap.min.js"></script>
<script type="text/javascript"
	src="js/bootstrap-3.3.0-dist/js/bootstrapValidator.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$('#searchForm').validate({
			// 			debug : true,
			errorPlacement : function(error, element) {
				error.appendTo(element.parent().next());
			},
			//失去焦点时验证
			onfocusout : function(element) {
				$(element).valid();
			},
			onkeyup : function(element) {
				$(element).valid();
			},
			focusInvalid : false,
			rules : {
				searchPhone : {
					required : true,
					digits : true,
					isMobile : true,
				},
				searchCode : {
					required : true,
					digits : true,
					searvhMsgCode : true
// 					remote : {
// 						url : "loan/checkConfirmCode", //后台处理程序
// 						type : "post", //数据发送方式
// 						dataType : "json", //接受数据格式   
// 						cache : false,
// 						data : { //要传递的数据
// 							msgCode : function() {
// 								return $("#searchCode").val();
// 							},
// 							telphone : function() {
// 								return $("#searchPhone").val();
// 							}
// 						}
// 					}
				}
			},
			messages : {
				searchPhone : {
					required : "没有填写手机号码",
					digits : "只能输入数字",
					isMobile : "请正确填写您的手机号码",
				},
				searchCode : {
					required : "没有填写验证码",
					digits : "只能输入数字",
					remote : "请正确填写验证码"
				}
			}
		});
		$("#searchCode").focus(function() {
			if (!($("#searchPhone").valid())) {
				$("#searchCode").attr("disabled", "true");
			}
		});
		$("#searchCode").blur(function() {
			if ($("#searchCode").valid()) {
				if(InterValObj) {
					window.clearInterval(InterValObj);//停止计时器
				}
				$("#btnSendMsg").removeAttr("disabled");//启用按钮
				$("#btnSendMsg").val("重新获取验证码");
			}
		});
		$("#searchPhone").blur(function() {
			if ($("#searchPhone").valid()) {
				$("#searchCode").removeAttr("disabled");
			}
			if($("#searchCode").val() != '') {
				if($.data(document.getElementById("searchCode"), "previousValue"))
				{
					$.data(document.getElementById("searchCode"), "previousValue").old = null; 
				}
				$("#searchCode").valid();
			}
		});
		
		$("#btnSearch").click(function() {
			if($("#searchCode").val() != '') {
				if($.data(document.getElementById("searchCode"), "previousValue"))
				{
					$.data(document.getElementById("searchCode"), "previousValue").old = null; 
				}
				$("#searchCode").valid();
			}
			if($("#searchCode").valid()){
				if($('#searchForm').valid()){
					$("#btnSearch").attr("disabled", "true");
					var telphone = $('#searchPhone').val();
					var confirmCode = $('#searchCode').val();
					$.ajax({
								url : "loan/searchCustomApplyInfo?telphone=" + telphone + "&confirmCode=" + confirmCode,
								type : "POST",
								success : function(map) {
									var list = map.datas;
									$('#resultListTable').empty();
										if (list.length > 0) {
											$('#resultListTable').append("<thead><tr><th style='width: 7%'>序号</th><th style='width: 16%'>申请类型</th><th style='width: 20%'>申请时间</th><th style='width: 12%'>当前状态</th><th style='width: 12%'>业务经理</th><th style='width: 12%'>联系电话</th><th style='width: 10%'>操作</th></tr></thead>");
											for (i = 0; i < list.length; i++) {
												var set = list[i];
												if (set.status == '成功办理') {
													if (set.evaluateLevel == '' || set.evaluateLevel == null) {
														$('#resultListTable').append(
																		"<tbody><tr><td>"
																				+ (i + 1)
																				+ "</td><td>"
																				+ set.applyType
																				+ "</td><td>"
																				+ set.applyDate
																				+ "</td><td>"
																				+ set.status
																				+ "</td><td>"
																				+ set.managerName
																				+ "</td><td>"
																				+ set.telphone
																				+ "</td><td><a href='evaluation?applyId="
																				+ set.applyId
																				+ "&applyType="
																				+ set.applyType
																				+ "' class='btn btn-danger btn-xs'>待评价</a></td></tr></tbody>");
													} else {
														$('#resultListTable').append(
																		"<tbody><tr><td>"
																				+ (i + 1)
																				+ "</td><td>"
																				+ set.applyType
																				+ "</td><td>"
																				+ set.applyDate
																				+ "</td><td>"
																				+ set.status
																				+ "</td><td>"
																				+ set.managerName
																				+ "</td><td>"
																				+ set.telphone
																				+ "</td><td>已评价</td></tr></tbody>");
													}
												} else {
													$('#resultListTable').append(
																	"<tbody><tr><td>"
																			+ (i + 1)
																			+ "</td><td>"
																			+ set.applyType
																			+ "</td><td>"
																			+ set.applyDate
																			+ "</td><td>"
																			+ set.status
																			+ "</td><td>"
																			+ set.managerName
																			+ "</td><td>"
																			+ set.telphone
																			+ "</td><td></td></tr></tbody>");
												}
												$('#resultListDiv').css('display', '');
											}
										} else {
											$('#resultListTable').append("<tbody><tr class='info'><td colspan='7' align='center'><font size='4'>抱歉，系统未查询到任何申请记录</font></td></tr></tbody>");
											$('#resultListDiv').css('display', '');
										}
									$("#btnSearch").removeAttr("disabled");
								}
							});
				}
			}
		});
	});
	
	var InterValObj; //timer变量，控制时间
	var count = 60; //间隔函数，1秒执行
	var curCount;//当前剩余秒数
	
	function sendMessage() {
		if ($("#searchPhone").valid()) {
			var telphone = $('#searchPhone').val();
			$("#btnSendMsg").attr("disabled", "true");
			$.ajax({
				url : "loan/getMsgCode?telphone=" + telphone,
				type : "POST",
				success : function(map) {
					if (map.success) {
						curCount = count;
						$("#btnSendMsg").attr("disabled", "true");
						$("#btnSendMsg").val(
								map.message + ",请在" + curCount + "秒内输入验证码");
						InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
					} else {
						$("#btnSendMsg").removeAttr("disabled");
						$("#btnSendMsg").val(map.message + ",重新获取验证码");
					}
				},
			});
		}
	};
	
	//timer处理函数
	function SetRemainTime() {
		if (curCount == 0) {
			window.clearInterval(InterValObj);//停止计时器
			$("#btnSendMsg").removeAttr("disabled");//启用按钮
			$("#btnSendMsg").val("重新获取验证码");
		} else {
			curCount--;
			$("#btnSendMsg").val("请在" + curCount + "秒内输入验证码");
		}
	}

</script>

</head>
<body>

	<div id="header">
		<div id="header_con">
			<div class="header_l">
				<img src="images/logo.jpg" />
			</div>
			<div class="header_r">
				<span id="info1">2015年3月6日 星期五</span>
				<a href="/">返回首页</a>
				<script>
					timeFormat()
				</script>
			</div>
		</div>
	</div>

	<div id="content">
	<div id="content_bottom">
		<div id="content_con">
			<div>
			<div id="con_left">
				<div class="loan_title">
					<span>贷款业务</span>
				</div>
				
				<div class="loan_item">
					<ul class="left_list">
						<li>
							<a class="zl_title" href="../index.php?m=content&c=index&f=lists&catid=44&l=1&page=1">泰山福农卡</a>
						</li>
						<li>
							<a class="zl_title" href="../index.php?m=content&c=index&f=lists&catid=45&l=1&page=1">小微贷业务</a>
						</li>
						<li>
							<a class="zl_title" href="../index.php?m=content&c=index&f=lists&catid=46&l=1&page=1">农户贷款</a>
						</li>
						<li>
							<a class="zl_title" href="officialloanclause">公务员贷款</a>
						</li>
					</ul>
				</div>
				<div class="loan_title">
					<span>POS机业务申请</span>
				</div>
				<div class="loan_item">
					<ul class="left_list">
						<li>
							<a class="zl_title" href="../index.php?m=content&c=index&f=lists&catid=40&l=1&page=1">POS机申请</a>
						</li>
					</ul>
				</div>
				<div class="loan_title">
					<span>其他业务</span>
				</div>
				<div class="loan_item">
					<ul class="left_list">
						<li>
							<a class="zl_title" href="../index.php?m=content&c=index&f=lists&catid=48&l=1&page=1">集团客户业务</a>
						</li>
						<li>
							<a class="zl_title" href="../index.php?m=content&c=index&f=lists&catid=49&l=1&page=1">社区客户业务</a>
						</li>
					</ul>
				</div>
				<div class="loan_title">
					<span>进度查询</span>
				</div>
				<div class="loan_item">
					<ul class="left_list">
						<li>
							<a class="zl_title1" href="schedulesearch">进度查询</a>
						</li>
					</ul>
				</div>
				<div class="kefu1">
					<img src="images/kefu_tel.jpg">
				</div>
			</div>
			<div class="z_r_t">
				<span class="location">当前位置：<a href="/">首页</a>&nbsp;&gt; 
				<a href="../index.php?m=content&c=index&f=lists&catid=1&l=1&page=1">综合服务</a> &gt; 
				<a href="schedulesearch">进度查询</a></span>
			</div>
			<div id="con_right">
				<div class="z_con_t">
					<span>进度查询</span>
				</div>
				<div class="loan_form" style="margin-top: 25px;">
					<form id="searchForm" name="searchForm" method="post"
						class="form-horizontal" action="">
						<input type="hidden" id="telphone" name="telphone" /> <input
							type="hidden" id="confirmCode" name="confirmCode" />
						<div class="form-group" id="telphoneDiv">
							<label class="col-md-3 control-label">预留手机号</label>
							<div class="col-md-4">
								<input type="text" class="form-control" id="searchPhone"
									name="searchPhone" />
							</div>
							<label class="control-label"></label>
						</div>
						<div class="form-group">
							<label class="col-md-3 control-label">短信验证码</label>
							<div class="col-md-2">
								<input type="text" class="form-control" id="searchCode"
									name="searchCode" />
							</div>
							<label class="control-label"></label>
							<input id="btnSendMsg"
								name="btnSendMsg" type="button" class="btn btn-danger"
								onclick="sendMessage()" value="获取验证码" />
						</div>
						
						<div id="errorMsg" class="form-group form-group-bottom"
							style="display: none">
							<div class="col-md-5 col-md-offset-3">
								<div class="alert alert-danger alert-dismissable" style="margin-bottom: 0px;">
									<button type="button" class="close" data-dismiss="alert"
										aria-hidden="true">&times;</button>
									提交失败!
								</div>
							</div>
						</div>
						
						<div class="form-group form-group-bottom">
							<div class="col-md-5 col-md-offset-4">
								<button id="btnSearch" name="btnSearch" type="button" class="btn btn-danger btn-lg">查询</button>
							</div>
						</div>
					</form>
				</div>
				<div class="resultlist" style="margin-top: 25px; display: none;"
					id="resultListDiv">
					<table class="table table-hover" style="margin-bottom: 0;"
						id="resultListTable">
					</table>
				</div>
			</div>
			</div>
		</div>
		<div id="footer">
		枣庄农商银行 2015 版权所有 桂ICP备03023960号<br>
				Copyright 2012 XuDong network technology Co., LT
			</div>
		</div>
		<!-- end of content_con-->
	</div>
</body>
</html>